import React, { useEffect, useState } from 'react'
import axios from 'axios'

function Detail(props){
    const [list, setlist] = useState([])
    useEffect(()=>{
        if(props.type === 1){
            axios({
                url:'/api/mmdb/movie/v3/list/hot.json?ct=%E5%B9%BF%E5%B7%9E&ci=20&channelId=4'
            }).then(res =>{
                console.log(res.data.data.hot)
                setlist(res.data.data.hot);
            })
        }
        else{
            axios({
                url:'/ajax/comingList?ci=20&limit=10&movieIds=&token=&optimus_uuid=D6C04350DCD211ECA16AAB6147C9C886098B4993C3D64B5FB601C700E59DDC42&optimus_risk_level=71&optimus_code=10'
            }).then(res =>{
                console.log(res)
                
            })
        }
    },[props.type])
    return(
        <div>
            {
                list.map(item =>
                    <div key={item.videoId}>
                        {item.nm}
                    </div>
                    )
            }
        </div>
    )
}

export default function App() {
  const [type,settype] = useState(1);
  return (
    <div>
        <div onClick={()=>{
            settype(1);
        }}>正在热映</div>
        <div onClick={()=>{
            settype(2);
        }}>即将上映</div>
        <Detail type={type}></Detail>
    </div>
  )
}
